﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Admin.CYT369.Com.WebBase;

namespace user.admin.cyt369.com.Areas.UserAdmin.Controllers
{
    public partial class UsersController
    {
        #region Users
        [HttpGet]
        public ActionResult GetUsers()
        {
            int page = Request.Query.GetInteger("page", 0);
            int rows = Request.Query.GetInteger("rows", 20);
            int total = 0;

            string loginName = Request.Query.GetString("LoginName");
            string fullName = Request.Query.GetString("FullName");


            var items = user.admin.cyt369.com.services.Services.UserService.Instance.GetUsers(page, rows, ref total, loginName, fullName);

            return DefaultJson(new { total = total, rows = items });
        }

        [HttpGet]
        public IActionResult GetUserByID(long id)
        {
            var role = user.admin.cyt369.com.services.Services.UserService.Instance.GetUserByID(id);

            return DefaultJson(role);
        }
        #endregion


        #region UserLoginLogs
        [HttpGet]
        public ActionResult GetUserLoginLogs()
        {
            int page = Request.Query.GetInteger("page", 0);
            int rows = Request.Query.GetInteger("rows", 20);
            int total = 0;

            string loginName = Request.Query.GetString("LoginName");


            var items = user.admin.cyt369.com.services.Services.UserService.Instance.GetUserLoginLogs(page, rows, ref total, loginName);

            return DefaultJson(new { total = total, rows = items });
        }

        [HttpGet]
        public IActionResult GetUserLoginLogByID(long id)
        {
            var role = user.admin.cyt369.com.services.Services.UserService.Instance.GetUserLoginLogByID(id);

            return DefaultJson(role);
        }
        #endregion
    }
}